<?php
/**
 * Created by PhpStorm.
 * User: zd
 * Date: 2019/1/19
 * Time: 14:22
 */

namespace app\boss\service;


class Boss
{
    public $url = '';
    function __construct()
    {
        $this->url = config('setting.base_url');
    }
    /**
     * 获取成交率信息
     * @param $token
     * @return null
     */
    public function getAllDara($token,$time,$type){
        $url=$this->url."/boss/all";
        $params = [$time,$type];
        $result = curl_post($url,$token,$params);
        $data = json_decode($result);
        if ($data->code = 200){
            return $data->content;
        }else{
            return null;
        }
    }

    /**
     * 获取所有成交率信息
     * @param $token
     * @return null
     */
    public function getAllRateNum($token,$rate){
        $url=$this->url."/boss/rate";
        $params = $rate;
        $result = curl_post($url,$token,$params);
        $data = json_decode($result);
        if ($data->code = 200){
            return $data->content;
        }else{
            return null;
        }
    }

    /**
     * 获取所有订单
     * @param $token
     * @return null
     */
    public function getAllOrders($token,$time){
        $url=$this->url."/boss/order/".$time;
        $result = curl_get($url,$token);
        $data = json_decode($result);
        if ($data->code = 200){
            return $data->content;
        }else{
            return null;
        }
    }

    /**
     * 获取所有跟进信息
     * @param $token
     * @return null
     */
    public function getAllFollowData($token,$time){
        $url=$this->url."/boss/follow/".$time;
        $result = curl_get($url,$token);
        $data = json_decode($result);
        if ($data->code = 200){
            return $data->content;
        }else{
            return null;
        }
    }

    /**
     * 获取所有跟进信息
     * @param $token
     * @return null
     */
    public function getUserNum($token,$time){
        $url=$this->url."/boss/add/".$time;
        $result = curl_get($url,$token);
        $data = json_decode($result);
        if ($data->code = 200){
            return $data->content;
        }else{
            return null;
        }
    }

    /**
     * 获取行为分类统计
     * @param $token
     * @return null
     */
    public function getAllBehaviorData($token){
        $url=$this->url."/boss/behavior";
        $result = curl_get($url,$token);
        $data = json_decode($result);
        if ($data->code = 200){
            return $data->content;
        }else{
            return null;
        }
    }

    /**
     * 获取活跃度统计
     * @param $token
     * @return null
     */
    public function getAllActiveData($token,$time){
        $url=$this->url."/boss/active/".$time;
        $result = curl_get($url,$token);
        $data = json_decode($result);
        if ($data->code = 200){
            return $data->content;
        }else{
            return null;
        }
    }

    /**
     * 交互量统计
     * @param $token
     * @return null
     */
    public function getAllInteractionData($token){
        $url=$this->url."/boss/interaction";
        $result = curl_get($url,$token);
        $data = json_decode($result);
        if ($data->code = 200){
            return $data->content;
        }else{
            return null;
        }
    }

    /**
     * 用户条件排序
     * @param $token
     * @param $condition
     * @param $num
     * @return null
     */
    public function getUserByCondition($token,$condition,$num){
        $url=$this->url."/boss/condition";
        $params = [$condition,$num];
        $result = curl_post($url,$token,$params);
        $data = json_decode($result);
        if ($data->code = 200){
            return $data->content;
        }else{
            return null;
        }
    }

    /**
     * 获取成交率区间统计
     * @param $token
     * @param $begin
     * @param $end
     * @return null
     */
    public function getUserRateNUm($token,$begin,$end){
        $url=$this->url."/boss/condition/rate";
        $params = [$begin,$end];
        $result = curl_post($url,$token,$params);
        $data = json_decode($result);
        if ($data->code = 200){
            return $data->content;
        }else{
            return null;
        }
    }


    /**
     * 获取用户属性值
     * @param $token
     * @param $condition
     * @param $num
     * @return null
     */
    public function getUserData($token,$id){
        $url=$this->url."/boss/user/".$id;
        $result = curl_get($url,$token);
        $data = json_decode($result);
        if ($data->code = 200){
            return $data->content;
        }else{
            return null;
        }
    }
}